package com.blink.optimize.apis.staticmethod;

import org.junit.jupiter.api.Test;

/**
 * <ClassName>TestStaticMethod</ClassName>
 * <Description></Description>
 *
 * @Author liuxianzhao
 * @Date 2018年01月06日 12:10
 */
public class TestStaticMethod {
    //静态方法
    public static boolean staticMethod(String str) {
        return str == null || str.isEmpty();
    }

    //实例方法
    public boolean instanceMethod(String str) {
        return str == null || str.isEmpty();
    }

    @Test
    public void testStaticMethod() {
        long start1 = System.nanoTime();
        for (int i = 0; i < 1000000000; i++) {
            TestStaticMethod.staticMethod("abc");
        }
        System.out.println(System.nanoTime() - start1);
    }

    @Test
    public void testInstanceMethod() {
        long start2 = System.nanoTime();
        TestStaticMethod testStaticMethod = new TestStaticMethod();
        for (int i = 0; i < 1000000000; i++) {
            testStaticMethod.instanceMethod("abc");
        }
        System.out.println(System.nanoTime() - start2);
    }

}
